<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of HTTPRequestModel
 *
 * @author julien
 */
require_once 'Ressources/Constants.php';
require_once 'Classes/Model/Singleton.php';
class HTTPRequestModel implements Singleton {
    // Model destiné à gérer les variables de requetes HTTP 
    // $_GET et $_POST et $_SESSION
    
     private static $instance;
     
     protected function __construct() {

     }
     
     public function getInstance(){
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
     }
     
     public function __clone() {
         throw new Exception("You may not try to clone this object");
     }
 
    
    public function extractGETValue($name){
        $return = "";
        if(isset ($_GET[$name]) && !empty($_GET[$name])){
            $return .= $_GET[$name] ;
        }
        
        return $return;
    }
    
    public function extractPOSTValue($name){
        
        $return = "";
        if(isset ($_POST[$name]) && !empty($_POST[$name])){
            $return .= $_POST[$name] ;
        }
        
        return $return;
    }
    
    
    public function getRequest(){
        return $_SERVER['REQUEST_METHOD'];
    }
   
    
    
    
}

?>
